<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>提现记录管理</title>
	<meta name="decorator" content="default"/>
	<link href="${ctxStatic}/jquery-select2/3.4/select2.min.css" rel="stylesheet" />
	<script src="https://select2.github.io/vendor/js/jquery.min.js"></script>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js"></script>
	<script src="${ctxStatic}/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
	<script type="text/javascript">
		$(document).ready(function() {
			$(".js-example-basic-single").select2();
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
		
		
		
		var tag=0;
		function cancel(id){
			if(tag==id){
				return;
			}
			tag=id;
			
			var cause = $("#cause_"+id).val();
			$.ajax({
				type: 'POST',
				url: "${ctx}/jiujiu/jiuWithdrawalsLog/cancel",
				dataType: "json",
				cache:true,
				async:false,
				data: {id: id,cause:cause},
				success: function (data) {
					if('success'==data.msg){
						alert(data.message);
						location.reload();
					}else{
						alert("作废失败！");
						location.reload();
					}
				}
			});
			
			
			/* top.$.jBox.confirm('确认作废吗？','系统提示',function(v,h,f){
				if(v=='ok'){
					$.getJSON("${ctx}/jiujiu/jiuWithdrawalsLog/cancel",{id:id}, function(data){
		                 alert(data.message);
		                 if(data.msg=='success'){
		                	 $('#z'+id).html("已作废");
		                	 $('#az'+id).hide();
		                	 $('#zh'+id).hide();
		                 }
		            });				
				}
			},{buttonsFocus:1});
			top.$('.jbox-body .jbox-icon').css('top','55px');
			return false; */
			
		}
		
		function excel(){
			$('#searchForm').attr('action',"${ctx}/jiujiu/jiuWithdrawalsLog/excel");
			$('#searchForm').submit();
		}
		function search(){
			$('#searchForm').attr('action',"${ctx}/jiujiu/jiuWithdrawalsLog");
			$('#searchForm').submit();
		}
		
		function showStore(id){
			//var href="${ctx}/jiujiu/jiuStore?id="+id;
			var href="${ctx}/jiujiu/jiuBalancePaymentsLog?storeId="+id;
			top.$.jBox.open('iframe:'+href,'选择用户',$(top.document).width()-500,$(top.document).height()-320,{
							buttons:{"关闭":true},
							loaded:function(h){
								$(".jbox-content", top.document).css("overflow-y","hidden");
								$(".nav,.form-actions,[class=btn]", h.find("iframe").contents()).hide();
								$("body", h.find("iframe").contents()).css("margin","10px");
							}
						});
						return false;
			}
		
		
		//转账
		function transfer(id){
			top.$.jBox.confirm('确认转账吗？此操作不可撤回！','系统提示',function(v,h,f){
					if(v=='ok'){
						$.getJSON("${ctx}/jiujiu/jiuWithdrawalsLog/transfer",{id:id}, function(data){
			                 alert(data.message);
			                 if(data.msg=='success'){
			                	 
			                 }
			            });	
					}
				},{buttonsFocus:1});
				top.$('.jbox-body .jbox-icon').css('top','55px');
				return false;
		}
		
		
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/jiujiu/jiuWithdrawalsLog/">提现记录列表</a></li>
		<%-- <shiro:hasPermission name="jiujiu:jiuWithdrawalsLog:edit"><li><a href="${ctx}/jiujiu/jiuWithdrawalsLog/form">提现记录添加</a></li></shiro:hasPermission> --%>
	</ul>
	<form:form id="searchForm" modelAttribute="jiuWithdrawalsLog" action="${ctx}/jiujiu/jiuWithdrawalsLog/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		
		<label>订单号：</label><form:input path="startOrderNo" htmlEscape="false" maxlength="50" class="input-medium"/>  -至-
		<form:input path="endOrderNo" htmlEscape="false" maxlength="50" class="input-medium"/>
		<br />
		
		<label>门店名称 ：</label>
		<form:select path="storeId" class="js-example-basic-single">
			<form:option value="">全部</form:option>
			<c:forEach items="${JiuStoreList}" var="jiuStore">
                   <form:option value="${jiuStore.id}">${jiuStore.name}</form:option>
			</c:forEach>
       	</form:select>
       	
       	<label>厂家名称 ：</label>
		<form:select path="manufactorId" class="js-example-basic-single">
			<form:option value="">全部</form:option>
			<c:forEach items="${jiuManufactorList}" var="jiuManufactor">
                   <form:option value="${jiuManufactor.id}">${jiuManufactor.name}</form:option>
			</c:forEach>
       	</form:select>
       	
		<label> 状态：</label>
          <form:select path="status"   style="WIDTH: 130px">
               <form:option value="">全部</form:option>
               <form:option value="0">未审核</form:option>
               <form:option value="1">提现成功</form:option>
               <form:option value="2">提现失败</form:option>
               <form:option value="3">作废</form:option>
               <form:option value="300">未完结</form:option>
               <form:option value="400">已完结</form:option>
               <form:option value="500">总金额</form:option>
          </form:select>
         <br/>
         <label>提交时间 ：</label>
                <input id="startTime" name="startTime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
                        value="<fmt:formatDate value="${jiuWithdrawalsLog.startTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
                        onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
                	至
                <input id="endTime" name="endTime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
	                 value="<fmt:formatDate value="${jiuWithdrawalsLog.endTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
	                 onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
	       <br/>   <br/>         
	     <label>审核时间 ：</label>
                <input id="withStartTime" name="withStartTime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
                        value="<fmt:formatDate value="${jiuWithdrawalsLog.withStartTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
                        onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
                	至
                <input id="withEndTime" name="withEndTime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
	                 value="<fmt:formatDate value="${jiuWithdrawalsLog.withEndTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
	                 onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
                        
		&nbsp;<input id="btnSubmit" class="btn btn-primary" type="button" value="查询" onclick="javascript:search()"/>
		&nbsp;<input class="btn btn-primary" type="button" value="导出" onclick="javascript:excel()"/>
	</form:form>
	<tags:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered ">
		<thead><tr>
		<th>订单号</th>
		<th>门店名称</th>
		<th>厂家名称</th>
		<th>提现金额(元)</th>
		<th>使用积分</th>
		<th>手续费(元)</th>
		<th>实际转账(元)</th>
		<th>状态</th>
		<th>提交时间</th>
		<th>审核时间</th>
		<shiro:hasPermission name="jiujiu:jiuWithdrawalsLog:edit"><th>操作</th></shiro:hasPermission></tr></thead>
		<tbody>
		<c:forEach items="${page.list}" var="jiuWithdrawalsLog">
			<tr>
				<td>${jiuWithdrawalsLog.orderNo}</td>
				<td>${jiuWithdrawalsLog.name}</td>
				<td>${jiuWithdrawalsLog.manufactorName}</td>
				<td>${jiuWithdrawalsLog.money}</td>
				<td>${jiuWithdrawalsLog.point}</td>
				<td>${jiuWithdrawalsLog.poundageMoney}</td>
				<td>${jiuWithdrawalsLog.realMoney}</td>
				<td id="z${jiuWithdrawalsLog.id}">
					<c:choose>
					    <c:when test="${jiuWithdrawalsLog.status eq 0}">
					  		未审核
					    </c:when>
					    <c:when test="${jiuWithdrawalsLog.status eq 1}">
					  		提现成功
					    </c:when>
					    <c:when test="${jiuWithdrawalsLog.status eq 2}">
					  		提现失败
					    </c:when>
					    <c:when test="${jiuWithdrawalsLog.status eq 3}">
					  		已作废
					    </c:when>
					    <c:otherwise>
					    	异常
					    </c:otherwise>
					</c:choose>
				</td>
				<td><fmt:formatDate value="${jiuWithdrawalsLog.createTime}" type="both" pattern="yyyy-MM-dd HH:mm:ss" /></td>
				<td><fmt:formatDate value="${jiuWithdrawalsLog.withdrawalsTime}" type="both" pattern="yyyy-MM-dd HH:mm:ss" /></td>
				<shiro:hasPermission name="jiujiu:jiuWithdrawalsLog:edit">
				
				
				<%-- <td>
					<c:if test="${jiuWithdrawalsLog.status eq 0}">
						<a id="az${jiuWithdrawalsLog.id}" class="btn btn-success" href="javascript:cancel(${jiuWithdrawalsLog.id})">作废</a>
                   		<a id="zh${jiuWithdrawalsLog.id}" class="btn btn-success" href="javascript:transfer(${jiuWithdrawalsLog.id})">转账</a>
                    </c:if>
                    <a class="btn btn-success" href="javascript:showStore(${jiuWithdrawalsLog.storeId})">查看门店</a>
				
    				<a class="btn btn-success" href="${ctx}/jiujiu/jiuWithdrawalsLog/form?id=${jiuWithdrawalsLog.id}">修改</a>
					<a class="btn btn-danger" href="${ctx}/jiujiu/jiuWithdrawalsLog/delete?id=${jiuWithdrawalsLog.id}" onclick="return confirmx('确认要删除该提现记录吗？', this.href)">删除</a>
				</td> --%>
				
				<td nowrap="nowrap">
					<div class="btn-toolbar" style="margin: 0;">
						<c:set var="isModifyChuNa" value="${fn:indexOf(fns:getUser().roleIdList, '12') == -1}" scope="page"/>
				 		<c:set var="isModifyKuaiJi" value="${fn:indexOf(fns:getUser().roleIdList, '11') == -1}" scope="page"/>
						
						
					
						
						<c:if test="${isModifyChuNa && isModifyKuaiJi }">	<!-- 平台会计  无权作废 -->	
							<c:if test="${jiuWithdrawalsLog.status eq 0}">
								<a  class="btn btn-success" href="#"  data-toggle="modal" data-target="#myModal_${jiuWithdrawalsLog.id}">作废</a>
	<%-- 							<a id="az${jiuWithdrawalsLog.id}" class="btn btn-success" href="javascript:cancel(${jiuWithdrawalsLog.id})">作废</a> --%>
		                   		<%-- <a id="zh${jiuWithdrawalsLog.id}" class="btn btn-success" href="javascript:transfer(${jiuWithdrawalsLog.id})">转账</a> --%>
		                    </c:if>
	                   	</c:if>
	                    
	                     <c:if test="${jiuWithdrawalsLog.status ne 3}">
	                   		 <a class="btn btn-success" href="javascript:showStore(${jiuWithdrawalsLog.storeId})">查看门店</a>
	                    </c:if>
	                    
	                    <c:if test="${not empty jiuWithdrawalsLog.voucher }">
	                    	 <c:if test="${isModifyChuNa }">	<!-- 平台会计  无权充值 -->	
		                    	<c:if test="${jiuWithdrawalsLog.status eq 0}">
			                   		<a id="zh${jiuWithdrawalsLog.id}" class="btn btn-success" href="javascript:transfer(${jiuWithdrawalsLog.id})">转账</a>
			                    </c:if>
			                 </c:if>
		                    
	                    	<c:if test="${jiuWithdrawalsLog.status ne 3 }">
	                     		<a class="btn btn-success" href="${ctx}/jiujiu/jiuWithdrawalsLog/viewVoucher?id=${jiuWithdrawalsLog.id}">查看凭证</a>
	                    	</c:if>
	                    	<c:if test="${jiuWithdrawalsLog.status eq 3}">
		                   		<a  href="#"  class="btn btn-success" data-toggle="modal" data-target="#myModal1_${jiuWithdrawalsLog.id}" >作废详情</a>
		                    </c:if>
	                    </c:if>
	                   	 <c:if test="${isModifyChuNa }">	<!-- 平台会计  无权充值 -->	
		                     <c:if test="${jiuWithdrawalsLog.status ne 3 }">
		                     	<c:if test="${empty jiuWithdrawalsLog.voucher }">
	                     			<a class="btn btn-success" href="${ctx}/jiujiu/jiuWithdrawalsLog/formVoucher?id=${jiuWithdrawalsLog.id}">上传凭证</a>
	                     		</c:if>
	                     		
								<c:if test="${isModifyChuNa && isModifyKuaiJi}">	<!-- 平台出纳  无权修改凭证 -->
		                     		<c:if test="${not empty jiuWithdrawalsLog.voucher }">
		                     			<a class="btn btn-danger" href="${ctx}/jiujiu/jiuWithdrawalsLog/formVoucher?id=${jiuWithdrawalsLog.id}">修改凭证</a>
		                   			</c:if>
	                   			</c:if>
	                   		</c:if>
                   		</c:if>
	                     <c:if test="${empty jiuWithdrawalsLog.voucher }">
	                     	
	                   		<c:if test="${jiuWithdrawalsLog.status eq 3}">
		                   		<a  href="#"  class="btn btn-success" data-toggle="modal" data-target="#myModal1_${jiuWithdrawalsLog.id}">作废详情</a>
		                    </c:if>
	                   	 </c:if>
	                   <%--  <a class="btn btn-success"  href="#"  data-toggle="modal" data-target="#myModal_${jiuWithdrawalsLog.id}">作废</a> --%>
	                  
	                    <!-- 回复内容 -->
						<div id="myModal_${jiuWithdrawalsLog.id}" class="modal hide fade" tabindex="-1" 
							style="width:500px;margin-left:-400px;" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
							<div class="modal-header">
								<button type="button" class="close" data-dismiss="modal"
									aria-hidden="true">×</button>
								<h3 id="myModalLabel">系统提示</h3>
							</div>
							<div class="modal-body">
								<div class="control-group"   style="border-bottom: 0px solid rgb(241, 241, 241);">
									<label class="control-label" style="float:left;"  ><br>作废原因:</label>
									<div class="controls" style="float:left;"  ><br>
										<input type="text" id="cause_${jiuWithdrawalsLog.id }"  style="float:left;"  >
									</div>
								</div>
							</div>
							<div class="modal-footer">
								<a href="javascript:cancel(${jiuWithdrawalsLog.id})"  class="btn btn-danger">确定</a>
								<button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
							</div>
						</div> 
						<!-- 回复内容 结束-->
						
						 <!-- 回复内容 -->
						<div id="myModal1_${jiuWithdrawalsLog.id}" class="modal hide fade" tabindex="-1" 
							style="width:500px;margin-left:-400px;" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
							<div class="modal-header">
								<button type="button" class="close" data-dismiss="modal"
									aria-hidden="true">×</button>
								<h3 id="myModalLabel">系统提示</h3>
							</div>
							<div class="modal-body">
								<div class="control-group"   >
									<label class="control-label" style="float:left;"  >作废人:${jiuWithdrawalsLog.zhuanzhangPeople }</label>
									<div class="controls" style="float:left;"  >
										
									</div>
									<br><br>
									<label class="control-label" style="float:left;"  >作废时间:${jiuWithdrawalsLog.zhuanzhangTime }</label>
									<div class="controls" style="float:left;"  >
									</div>
									<br><br>
									<label class="control-label" style="float:left;"  ><br>作废原因:${jiuWithdrawalsLog.zhuanzhangReason }</label>
									<div class="controls" style="float:left;"  ><br>
										
									</div>
								</div>
							</div>
							<div class="modal-footer">
								<button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
							</div>
						</div> 
						<!-- 回复内容 结束-->
						
					</div>
	
						
				</td>
				
				
				
				</shiro:hasPermission>
			</tr>
		</c:forEach>
		<tr>
			<td>--</td>
			<td>--</td>
			<td>--</td>
			<td>${map.moneySum}</td>
			<td>${map.pointSum}</td>
			<td>${map.poundageMoney}</td>
			<td>--</td>
			<td>--</td>
			<td>--</td>
			<td>--</td>
			<td>--</td>
		
		</tr>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
	
	
</body>
</html>
